﻿using System;
using System.Collections.Generic;
using System.Text;
using ExpressionUtil.Exceptions;
using ExpressionUtil.Common;

namespace ExpressionUtil.Extension
{
    /// <summary>
    /// 扩展函数使用的返回值类型
    /// </summary>
    public class ExtFunctionValueInfo
    {
        /// <summary>
        /// 数字数据
        /// </summary>
        private decimal decimalData;

        /// <summary>
        /// 布尔数据
        /// </summary>
        private bool booleanData;

        /// <summary>
        /// 当前数据类型
        /// </summary>
        private ExecuteRunTimeType type;

        /// <summary>
        /// 默认构造函数
        /// </summary>
        internal ExtFunctionValueInfo()
        {
            this.type = ExecuteRunTimeType.None;
            this.decimalData = 0;
            this.booleanData = false;
        }

        /// <summary>
        /// 获取或设置当前数据类型
        /// </summary>
        public ExecuteRunTimeType Type
        {
            get
            {
                return this.type;
            }
            set
            {
                this.type = value;
            }
        }

        /// <summary>
        /// 获取或设置数字数据
        /// </summary>
        public decimal DecimalData
        {
            get
            {
                CheckHelper.IsDecimalType(this.type, "Value'type is not decimal,current type is " + this.type.ToString().ToLower() + ".");
                return this.decimalData;
            }
            set
            {
                this.decimalData = value;
                this.type = ExecuteRunTimeType.Decimal;
            }
        }

        /// <summary>
        /// 获取或设置布尔数据
        /// </summary>
        public bool BooleanData
        {
            get
            {
                CheckHelper.IsBoolType(this.type, "Value'type is not boolean,current type is " + this.type.ToString().ToLower() + ".");
                return this.booleanData;
            }
            set
            {
                this.booleanData = value;
                this.type = ExecuteRunTimeType.Bool;
            }
        }
    }
}
